package com.szh.zx.duoxiancheng.asynctask;

import java.util.Timer;
import java.util.TimerTask;

/**
 * 定时任务-简单例子（相对时间）
 * */
public class BasicTimer {
    public static void main(String[] args) throws InterruptedException {
        Timer timer = new Timer();
        timer.schedule(new DelayTask(),1000);
        Thread.sleep(2000);
        timer.cancel();
    }
    static class DelayTask extends TimerTask{

        @Override
        public void run() {
            System.out.println("delay task");
        }
    }
}
